/**
 * 功能描述 收费行编辑
 */

define(function(require, exports, module) {
	var Grid = require("grid");
	var enmu = require("enums");
	var fetchProperties = require("../constant/fetchProperties");
	var applyGridEvents = require("../handler/applyGridEvents");

	var instance = {
		initComponent : function(params, widget) {
			var applyGrid = new Grid(
					{
						parentNode : ".J-applygrid",
						autoRender : false,
						model : {
							id : "memberRegisterApplyGrid",
							head : {
								title : "已报名人员",
								//items : [ {
									//id : "applyAdd",
									//type : "button",
									buttons:[{
										id:"addPerson",
										icon: "icon-plus",
										handler : function() {
											applyGridEvents.addApply(widget);
										}
									}]
								//} ]
							},
							url : "api/signupregister/query",
							params : function() {
								var subnav = widget.get("subnav");
								var fromData = widget.get("form").getData();

								var obj = {
									"planItemGroup.planItem.pkPlanItem" : fromData.pkPlanItem,
									"planItemGroup.servicePoint.pkServicePoint" : fromData.pkServicePoint,
									"fetchProperties" : fetchProperties.applyGrid
								};
								return obj;
							},
							columns : [ {
								name : "personalInfo.idNumber",
								label : "身份证号",
							}, {
								name : "personalInfo.name",
								label : "姓名",
							}, {
								name : "personalInfo.sex",
								label : "性别",
								format : function(data, row) {
									return data.value || "";
								},
							}, {
								name : "personalInfo.mobilePhone",
								label : "手机号",
							}, {
								name : "member",
								label : "是否是会员",
								format : function(data, row) {
									return data ? "是":"否";
								}
							}, {
								name : "travelContract.memberCertificates",
								label : "会员证号",
								format : function(data, row) {
									return row.travelContract.member.personalInfo.idNumber+"-"+row.travelContract.member.personalInfo.name+
	                      			"-"+row.travelContract.productRule.product.name+"-"+row.travelContract.memberCertificates;
								},
							}, {
								name : "signUpDate",
								label : "报名日期",
								format : "date",
								formatparams : {
									mode : "YYYY-MM-DD"
								}
							}, {
								name : "operate",
								label : "操作",
								format : "button",
								formatparams : [ {
									key : "edit",
									icon : "icon-edit",
									handler : function(index, data, rowEle) {
										applyGridEvents.editApply(data,widget);
									}
								}, {
									key : "delete",
									icon : "icon-remove",
									handler : function(index, data, rowEle) {
										applyGridEvents.deleteApply(data,widget);
									}
								} ]
							} ]
						}
					});
			widget.set("applyGrid", applyGrid);
		}
	};
	module.exports = instance;
});
